package com.edfu.core.commons.persistence.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.edfu.core.commons.persistence.Discountable;
import com.edfu.core.commons.persistence.Sellable;

@Entity
@Table(name = "resources")
public class ResourceEntity implements Sellable, Discountable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    @Column(name = "name", nullable = false)
    private String name;

    @Column(name = "description", nullable = true)
    private String description;

    @Column(name = "uuid", nullable = false)
    private String uuid;

    @Column(name = "type", nullable = false)
    private String type;
    
    @Column(name = "price", nullable = true)
    private double price;
    
    @Column(name = "units", nullable = true)
    private String units;
    
    @Column(name = "exposed", nullable = false)
    private boolean exposed = false;
    
    @ManyToOne
	@JoinColumn(name = "category_id", nullable = false)
	private CategoryEntity category;
    
    @Column(name = "discType", nullable = true)
    private String discType;
    
    @Column(name = "discValue", nullable = true)
	private double discValue;
    
    @Column(name = "discStart", nullable = true)
	private long discStart;
    
    @Column(name = "discEnd", nullable = true)
	private long discEnd;

    public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }

    public String getUuid() {
		return uuid;
	}
	public void setUuid(String uuid) {
		this.uuid = uuid;
	}
	
	public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    
    public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	
	public String getUnits() {
		return units;
	}
	public void setUnits(String units) {
		this.units = units;
	}
	
	public boolean isExposed() {
		return exposed;
	}
	public void setExposed(boolean exposed) {
		this.exposed = exposed;
	}
	
	public String getDiscType() {
		return discType;
	}
	public void setDiscType(String discType) {
		this.discType = discType;
	}
	
	public double getDiscValue() {
		return discValue;
	}
	public void setDiscValue(double discValue) {
		this.discValue = discValue;
	}
	
	public long getDiscStart() {
		return discStart;
	}
	public void setDiscStart(long discStart) {
		this.discStart = discStart;
	}
	
	public long getDiscEnd() {
		return discEnd;
	}
	public void setDiscEnd(long discEnd) {
		this.discEnd = discEnd;
	}
	
	public CategoryEntity getCategory() {
		return category;
	}
	public void setCategory(CategoryEntity category) {
		this.category = category;
	}
	
	@Override
    public String toString() {
        return "ResourceEntity{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", uuid='" + uuid + '\'' +
                '}';
    }    
	
}
